package com.bi.onlineEducation.dao;

import com.bi.onlineEducation.domain.CoursePo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Repository
public interface CourseDao extends JpaRepository<CoursePo, Integer> {

    @Modifying
    @Transactional
    @Query(value = "update course set c_status = (:cStatus) where c_id = (:id)", nativeQuery = true)
    void updateCStatusById(boolean cStatus, Integer id);

    List<CoursePo> findAllBylId(Integer lId);

    List<CoursePo> findAllBycStatus(Boolean cStatus);
}